<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	
    	$this->display();
    }
    
    public function login(){
    	if($_POST['user_name'] && $_POST['password']){
    	    $_POST['password'] = md5($_POST['password']);
            $res = D('member')->getAdminInfo($_POST);
    		if($res){
    			$_SESSION['admin'] = $res;
    			$return_array = array(
    				'code' => '10000',
    				'msg' => '登陆成功'
    			);
    		}else{
    			$return_array = array(
    				'code' => '10010',
    				'msg' => '账号密码错误'
    			);
    		}
    		echo json_encode($return_array);
    	}
    }
    public function logout(){
        $_SESSION['admin']  = '';
        $this->redirect(U('Login/index'));
    }
}